import Vue from 'vue';
import Main from './main.vue';

const LoadingConstructor = Vue.extend(Main);
const instance = new LoadingConstructor();
let timer;

instance.$mount();

document.body.appendChild(instance.$el);
// 开启方法
const mivaLoading = () => new Promise((resolve) => {
    instance.isShow = true;
    clearTimeout(timer);
    timer = setTimeout(() => {
        resolve();
    // }, 1200);
    }, 200);
});

// 关闭方法
mivaLoading.close = () => new Promise((resolve) => {
    clearTimeout(timer);
    instance.isShow = false;
    resolve();
});

export default mivaLoading;
